#include "CalibrationSetting.h"

CalibrationSetting::CalibrationSetting () :
		_iniSettings ("../Data/setting.ini", QSettings::IniFormat)
{
	if (!_iniSettings.contains ("CheckBoard/Rows")) {
		// New settings created, write default values
		setCheckCols (7);
		setCheckRows (5);
		setCheckSize ("10");
		setMaxFrames (10);
	}
}

CalibrationSetting::~CalibrationSetting ()
{

}

int CalibrationSetting::getCheckRows () const
{
	return _iniSettings.value ("CheckBoard/Rows").toInt ();
}

int CalibrationSetting::getCheckCols () const
{
	return _iniSettings.value ("CheckBoard/Cols").toInt ();
}

QString CalibrationSetting::getCheckSize () const
{
	return _iniSettings.value ("CheckBoard/Size").toString ();
}

float CalibrationSetting::getCheckSizeF () const
{
	return _iniSettings.value ("CheckBoard/Size").toFloat ();
}

int CalibrationSetting::getMaxFrames () const
{
	return _iniSettings.value ("Intrinsic/MaxFrames").toInt ();
}

void CalibrationSetting::setCheckRows (int val)
{
	_iniSettings.setValue ("CheckBoard/Rows", val);
}

void CalibrationSetting::setCheckCols (int val)
{
	_iniSettings.setValue ("CheckBoard/Cols", val);
}

void CalibrationSetting::setCheckSize (QString valStr)
{
	bool isValid;
	valStr.toFloat (&isValid);
	if (isValid)
		_iniSettings.setValue ("CheckBoard/Size", valStr);
}

void CalibrationSetting::setMaxFrames (int val)
{
	_iniSettings.setValue ("Intrinsic/MaxFrames", val);
}
